package com.qipay.baas.mapper;

import com.qipay.baas.model.AlipayTransferLog;
import com.qipay.baas.model.AlipayTransferLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface AlipayTransferLogMapper {
    @SelectProvider(type=AlipayTransferLogSqlProvider.class, method="countByExample")
    int countByExample(AlipayTransferLogExample example);

    @Delete({
        "delete from `alipay_transfer_log`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `alipay_transfer_log` (`trade_no`, `sp_id`, ",
        "`amount`, `cp_id`, `create_time`, ",
        "`status`, `transfer_no`,collection_alipay,",
        "`remark`)",
        "values (#{tradeNo,jdbcType=CHAR}, #{spId,jdbcType=BIGINT}, ",
        "#{amount,jdbcType=INTEGER}, #{cpId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{status,jdbcType=TINYINT}, #{transferNo,jdbcType=CHAR}, #{collectionAlipay,jdbcType=VARCHAR}, ",
        "#{remark,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(AlipayTransferLog record);

    @InsertProvider(type=AlipayTransferLogSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(AlipayTransferLog record);

    @SelectProvider(type=AlipayTransferLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="trade_no", property="tradeNo", jdbcType=JdbcType.CHAR),
        @Result(column="sp_id", property="spId", jdbcType=JdbcType.BIGINT),
        @Result(column="amount", property="amount", jdbcType=JdbcType.INTEGER),
        @Result(column="cp_id", property="cpId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="transfer_no", property="transferNo", jdbcType=JdbcType.CHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<AlipayTransferLog> selectByExampleWithRowbounds(AlipayTransferLogExample example, RowBounds rowBounds);

    @SelectProvider(type=AlipayTransferLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="trade_no", property="tradeNo", jdbcType=JdbcType.CHAR),
        @Result(column="sp_id", property="spId", jdbcType=JdbcType.BIGINT),
        @Result(column="amount", property="amount", jdbcType=JdbcType.INTEGER),
        @Result(column="cp_id", property="cpId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="transfer_no", property="transferNo", jdbcType=JdbcType.CHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<AlipayTransferLog> selectByExample(AlipayTransferLogExample example);

    @Select({
        "select",
        "`id`, `trade_no`, `sp_id`, `amount`, `cp_id`, `create_time`, `status`, `transfer_no`, ",
        "`remark`",
        "from `alipay_transfer_log`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="trade_no", property="tradeNo", jdbcType=JdbcType.CHAR),
        @Result(column="sp_id", property="spId", jdbcType=JdbcType.BIGINT),
        @Result(column="amount", property="amount", jdbcType=JdbcType.INTEGER),
        @Result(column="cp_id", property="cpId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="transfer_no", property="transferNo", jdbcType=JdbcType.CHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    AlipayTransferLog selectByPrimaryKey(Long id);

    @UpdateProvider(type=AlipayTransferLogSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AlipayTransferLog record);

    @Update({
        "update `alipay_transfer_log`",
        "set `trade_no` = #{tradeNo,jdbcType=CHAR},",
          "`sp_id` = #{spId,jdbcType=BIGINT},",
          "`amount` = #{amount,jdbcType=INTEGER},",
          "`cp_id` = #{cpId,jdbcType=BIGINT},",
          "`create_time` = #{createTime,jdbcType=TIMESTAMP},",
          "`status` = #{status,jdbcType=TINYINT},",
          "`transfer_no` = #{transferNo,jdbcType=CHAR},",
          "`remark` = #{remark,jdbcType=VARCHAR}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(AlipayTransferLog record);
}